<?php
//判断是否POST传递参数,注意区分大小写
    if ($_SERVER["REQUEST_METHOD"] != "POST") {
        echo("<span class='result_false'>提交方法错误!</span>");
    } else {
        if (isset($_POST['user_id'])
            && isset($_POST['user_name'])
            && isset($_POST['user_passwd'])
        )

            $user_id = $_POST['user_id'];
        $user_name   = $_POST['user_name'];
        $user_passwd = $_POST['user_passwd'];

        include("user_db_connect.php");

//    写入和读取之前必须用这一句更改提交的中文字符编码
        mysqli_query($link, "set names 'utf8'");
        $sql = "update tbl_user2
            set col_user_name = '$user_name', col_user_passwd = '$user_passwd'
            where col_user_id = '$user_id'";

        mysqli_query($link, $sql);

        if (mysqli_errno($link)) {
            printf("<span class='result_false'>更新失败!<br /><br />错误代码: %d<br />%s</span>", mysqli_errno($link), mysqli_error($link));
        } else {
            echo("<span class='result_ok'>更新成功!</span>");
        }
    }
    mysqli_close($link);
?>